package com.jyb.qiyefuwu.view.fragment.usercenter;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.jyb.qiyefuwu.R;
import com.jyb.qiyefuwu.databinding.FragmentAiAttentionBinding;
import com.jyb.qiyefuwu.uitls.CommPagerAdapter3;
import com.swgk.core.base.AppLazyFragment;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;

/**
 * @author: 陈方凯
 * @date: 2021/09/17
 * @Description: 服务智能关注
 */
public class ServiceAiAttentionFragment extends AppLazyFragment {

    FragmentAiAttentionBinding mBinding;

    private ArrayList<Fragment> mFragments = new ArrayList<>();
    private String[] type = new String[]{"知产", "服务", "需求"};
    private int index = 0;

    public static ServiceAiAttentionFragment newInstance() {
        ServiceAiAttentionFragment fragment = new ServiceAiAttentionFragment();
        Bundle bundle = new Bundle();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @org.jetbrains.annotations.Nullable
    @Override
    public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_ai_attention, container, false);
        init();
        return mBinding.getRoot();
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }


    private void init() {
        mFragments.add(IntellectualPropertyFollowFragment.newInstance());
        mFragments.add(ServiceFollowListFragment.newInstance());
        mFragments.add(NeedFollowParentFragment.newInstance("2"));
        CommPagerAdapter3 pagerAdapter = new CommPagerAdapter3(getChildFragmentManager(), mFragments, type);
        mBinding.viewpager.setOffscreenPageLimit(type.length);
        mBinding.viewpager.setAdapter(pagerAdapter);
        mBinding.tabLayout.setupWithViewPager(mBinding.viewpager);
        mBinding.tabLayout.getTabAt(index).select();
    }

    @Override
    public void onClick(View v) {

    }


    public void refreshView() {

    }

    @Override
    public boolean isUseEventBus() {
        return true;
    }

    @Override
    protected void onLazyLoad() {
        refreshView();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

    }
}
